<template>
  <div class="common-layout">
    <el-container>

      <el-header style="background-color: #6495ED;">
          <div style="color: white;"><h3>WMS仓库系统欢迎您的登录&#160&#160&#160 {{ a.username }}({{ a.rolename }})</h3></div>      
          <div style="float: right;margin: -46px auto;"><el-button type="danger" @click="outlogin()">退出登录</el-button></div>
      </el-header>
      <el-container>
        <el-aside width="200px" >
              <el-menu
        default-active="basicdata"
        class="el-menu-vertical-demo"
        @open="handleOpen"
        @close="handleClose"
        router
      >
        <el-menu-item index="basicdata">
          <el-icon><House /></el-icon>
          <span>首页(熊开元)</span>
        </el-menu-item>
        <el-sub-menu index="1">
          <template #title>
            <el-icon><FolderChecked /></el-icon>
            <span>经营看板</span>
          </template>
          <el-menu-item-group>
            <el-menu-item index="/ledger">库存台账（王春雷）</el-menu-item>
            <el-menu-item index="/inventory-flow">库存流水</el-menu-item>
          </el-menu-item-group>
        </el-sub-menu> 
        <el-sub-menu index="2">
          <template #title>
            <el-icon><FolderChecked /></el-icon>
            <span>基础数据</span>
          </template>
          <el-menu-item-group>
            <el-menu-item index="/orderform">货品信息(熊开元)</el-menu-item>
            <el-menu-item index="/WareHouserView">仓库信息(李诚)</el-menu-item>
            <el-menu-item index="/CodeView">入库管理(李诚)</el-menu-item>
            <el-menu-item index="/OrderFormView">订单管理(李诚)</el-menu-item>
          </el-menu-item-group>
        </el-sub-menu>
        <!-- <el-sub-menu index="3">
          <template #title>
            <el-icon><FolderChecked /></el-icon>
            <span>出入库管理</span>
          </template>
          <el-menu-item-group>
            <el-menu-item index="">入库单</el-menu-item>
            <el-menu-item index="">出库单</el-menu-item>
          </el-menu-item-group>
        </el-sub-menu> -->
        <el-sub-menu index="4">
          <template #title>
            <el-icon><FolderChecked /></el-icon>
            <span>库存管理</span>
          </template>
          <el-menu-item-group>
            <el-menu-item index="/Allot">库存调拨(弓嘉浩)</el-menu-item>
           <el-menu-item index="/takestock">库存盘点(弓嘉浩)</el-menu-item> 
          </el-menu-item-group>
        </el-sub-menu>
                <el-sub-menu index="5">
          <template #title>
            <el-icon><FolderChecked /></el-icon>
            <span>统计报表</span>
          </template>
          <el-menu-item-group>
            <el-menu-item index="inOuStatistics">出入库流水(熊开元)</el-menu-item>
            <!-- <el-menu-item index="">库存盘点</el-menu-item>
            <el-menu-item index="">调拨统计</el-menu-item>
            <el-menu-item index="">库存分布</el-menu-item>
            <el-menu-item index="">仓库汇总</el-menu-item>
            <el-menu-item index="">出入库类型汇总</el-menu-item> -->
          </el-menu-item-group>
        </el-sub-menu>
        <el-sub-menu index="6">
          <template #title>
            <el-icon><Setting /></el-icon>
            <span>系统设置</span>
          </template>
          <el-menu-item-group>
            <el-menu-item index="coderule">编码管理(熊开元)</el-menu-item>
            <!-- <el-menu-item index="">个人信息</el-menu-item> -->
          </el-menu-item-group>
        </el-sub-menu>
      </el-menu>
        </el-aside>
        <el-main style="background-color:aliceblue;height: 100vh;">
            <router-view ></router-view>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>
<script lang="ts" setup>
const a=useCounterStore();
const outlogin=()=>{
  if(confirm("确认退出吗？"))
  {
    a.islogin=false;
    a.userid="";
    a.username="";
    a.rolename="";
    router.push("/")
    ElMessage.error("退出成功")
  }
}
onMounted(()=>{
  router.push("basicdata")
})
import router from '@/router';
import { useCounterStore } from '@/stores/counter'
import {
  Document,
  FolderChecked,
  House,
  Menu as IconMenu,
  Location,
  Setting,
} from '@element-plus/icons-vue'
import { ElMessage } from 'element-plus';
import { onMounted, ref } from 'vue';
import axios from 'axios'

const handleOpen = (key: string, keyPath: string[]) => {
  console.log(key, keyPath)
}
const handleClose = (key: string, keyPath: string[]) => {
  console.log(key, keyPath)
}
const inventoryList = ref([])
const loading = ref(false)
const fetchInventoryList = async () => {
  loading.value = true
  try {
    // 如果有查询条件，放到 data 里
    const { data } = await axios.get('/api/goods-management/goods-list', {/* 查询条件 */})
    inventoryList.value = data.data // 具体字段根据后端返回结构调整
  } catch (e) {
    // 错误处理
  } finally {
    loading.value = false
  }
}
onMounted(() => {
  fetchInventoryList()
})
</script>